<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">  
<title>专利协同服务网络平台</title>
<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-3.2.1.min.js"></script>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer.js"></script>
</head>
<body>
	<div class="place">
		<span>位置：</span>
		<ul class="placeul">
			<li><a href="#">首页</a></li>
			<li><a href="#" onClick="javascript:history.back();">沟通交流</a></li>
			<li><a href="#">提出问题</a></li>
		</ul>
    </div>
    <div class="formbody">
		<div class="formtitle"><span>提出问题</span></div>
		<ul class="forminfo">
			<li><label>问题标题</label><input id="title" name="title" type="text" class="dfinput" /></li>
			<li><label>问题内容</label><textarea  id="content" name="content" cols="" rows="" class="textinput"></textarea></li>
			<li><label>&nbsp;</label><input type="button" onclick="submitForm()" class="btn" value="提交" style="width:80px;"/>
				<span id="errorMsg" style="color:red; margin-top:20px; margin-left:90px;"></span>
			</li>
		</ul> 
    </div>
    <input class="btn btn-primary" style="margin-left: 77%;margin-top: 7%;"   onclick="closeLayer()" type="button" value="&nbsp;&nbsp;关闭&nbsp;&nbsp;">
    <script type="text/javascript">
    	function submitForm(){
    		var patentId = "${patentId}";
    		var title = $("#title").val();
    		var content = $("#content").val();
    		if((title == null || title == "")&&(content == null || content == "")){
    			$("#errorMsg").html("问题标题和问题内容不能为空!");
    		} else if (title == null || title == ""){
    			$("#errorMsg").html("问题标题不能为空!");
    		} else if (content == null || content == ""){
    			$("#errorMsg").html("问题内容不能为空!");
    		} else {
    			$.ajax({
    				type:"post",
    				url:"${pageContext.request.contextPath}/poster/postQuestion.action",
    				data:{"title":title,"content":content,"patentId":patentId},
    				dataType:"text",
    				success:function(data){
    					if(data == "success"){
    						layer.msg("问题提交成功");
    						setTimeout(function(){
    							window.location.href="${pageContext.request.contextPath}/poster/topostlist.action?patentId=${patentId}";
    						},300);
    					} else {
    						layer.msg("问题提交失败,请重试");
    						setTimeout(function(){
    							console.log(data);
    							history.back();
    						},300);
    					}
    				}
    			});
    		}
    	}
    	function closeLayer(){
			var index=parent.layer.getFrameIndex(window.name);
			window.parent.location.reload();
			parent.layer.close(index);
		}
    </script>
</body>
</html>